package struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {
    public FullForm() {
        
    }
    
    public static ActionForm full(String formPath, HttpServletRequest request) {
        ActionForm form = null;
        try{
            Class clazz = Class.forName(formPath);
            form = (ActionForm)clazz.newInstance();
            Field[] fdAttr = clazz.getDeclaredFields();
            for(Field fd : fdAttr) {
                fd.setAccessible(true);
                fd.set(form, request.getParameter(fd.getName()));
                fd.setAccessible(false);
            }
        }catch(Exception e){
            e.printStackTrace();
            System.out.println("严重：Form装载失败！");
        }
        
        return form;
    }
}
